<template>
  <div class="main">
    <div>
      <!-- 二级路由插座 -->
      <router-view></router-view>
    </div>
    <!-- 底部导航栏 选中标签颜色active-color 未选中标签颜色inactive-color-->
    <div>
      <van-tabbar
        v-model="activeTabbarIndex"
        active-color="#DB9A9D"
        inactive-color="#656565"
        route
      >
        <van-tabbar-item
          v-for="(item, index) in tabbarData"
          :key="index"
          :to="item.to"
        >
          <span>{{ item.title }}</span>
          <template #icon="props">
            <!--props插槽名称 active插槽自带属性 -->
            <img :src="props.active ? item.activeIcon : item.InactiveIcon" />
          </template>
        </van-tabbar-item>
      </van-tabbar>
    </div>
  </div>
</template>

<script>
export default {
  name: "Main",
  data() {
    return {
      activeTabbarIndex: 0,
      tabbarData: [
        {
          title: "推荐",
          activeIcon: require("../assets/images/home_active.png"),
          InactiveIcon: require("../assets/images/home.png"),
          //跳转的路由
          to: { name: "Home" },
        },
        {
          title: "音乐榜",
          activeIcon: require("../assets/images/search_active.png"),
          InactiveIcon: require("../assets/images/search.png"),
          to: { name: "Searchs" },
        },
        {
          title: "听歌",
          activeIcon: require("../assets/images/hot_active.png"),
          InactiveIcon: require("../assets/images/hot.png"),
          to: { name: "Listen" },
        },

        {
          title: "视频",
          activeIcon: require("../assets/images/my_active.png"),
          InactiveIcon: require("../assets/images/my.png"),
          to: { name: "Mv" },
        },
      ],
    };
  },
};
</script>
<style lang="less" scoped>
.van-tabbar {
  background-color: #ededed;
}

</style>